<!DOCTYPE HTML>
<html>
<head>
    <title>編輯</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <script src="/scripts/boot.js" type="text/javascript"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <link rel="stylesheet" href="/editor/common.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body>
<div id="form1" style="text-align: center">
    <span style="width:60px;display:inline-block;">分类OID：</span>
    <input id="objectId" name="objectId" class="mini-textbox" required="true" type="text" style="width:190px;" value="<%= result.objectId%>" readonly="readonly"/>
    <br/>
    <span style="width:60px;display:inline-block;">分类名称：</span>
    <input id="name" name="name" class="mini-textbox" required="true" type="text" style="width:190px;" value="<%= result.name%>"/>
    <br/>
    <span style="width:60px;display:inline-block;">排序序号：</span>
    <input id="sortNum" name="sortNum" class="mini-textbox" required="true" type="text" style="width:190px;" value="<%= result.sortNum%>"/>
    <br/>
</div>
<div style="margin: 30px 0;text-align: center">
    <a class="mini-button " iconCls="icon-ok" onclick="onOK()">确定</a>
    <a class="mini-button" iconCls="icon-cancel" onclick="onCancel">取消</a>
</div>
</body>
<script>
  mini.parse();
  function onOK() {
    var form = new mini.Form("#form1");
    form.validate();
    if (form.isValid() == false) return;
    var name = mini.get("name").getValue();
    var sortNum = mini.get("sortNum").getValue();
    var objectId = mini.get("objectId").getValue();
    $.ajax({
      type: "POST",
      url: "/getdata/editGoodsType",
      data: {
        objectId,
        sortNum,
        name
      },
      success: function (result) {
        if(result){
          CloseWindow('OK')
        } else {
          alert('更新分类名称失败！')
          return
        }
      }
    })
  }
  //    关闭窗口
  function CloseWindow(action) {
    if (action == "close" && form.isChanged()) {
      if (confirm("数据被修改了，是否先保存？")) {
        return false;
      }
    }
    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
    else window.close();
  }

  function onCancel(e) {
    CloseWindow("cancel");
  }
</script>
</html>